import {AbilityModel} from "../../controller/model/AbilityModel";
import Configer from "../../frame/apiModel/config/Configer";
import {FinalKey} from "../../constant/FinalConstant";
import {UnitModel} from "../../frame/apiModel/adapterModel/model3/UnitModel";
import {ItemModel} from "../../frame/apiModel/adapterModel/model3/ItemModel";
import {PlayerModel} from "../../frame/apiModel/adapterModel/model4/PlayerModel";
import {LocModel} from "../../frame/apiModel/base/LocModel";
import {ModelFactory} from "../../frame/apiModel/adapterModel/model5/ModelFactory";

export default class OneClickGetSkillModel extends AbilityModel {
    abilityId: string = Configer.getFinal(FinalKey.oneClickGet) as string;

    actionFun = (activeUnit: UnitModel, activeItem: ItemModel, targetUnit: UnitModel, targetItem: ItemModel, activePlayer: PlayerModel, targetPlayer: PlayerModel, spellId: string, spellLoc: LocModel)  => {
        let success;
        this.oneClickGet(activeUnit);
        return success;
    }

    oneClickGet(activeUnit: UnitModel) {
        const range = 300;
        const loc = activeUnit.loc;
        ModelFactory.getInstance().mapItemsInRange(loc, range, (item) => {
            if (item.show) {
            } else {
                return;
            }
            ModelFactory.getInstance().unitAddItem(activeUnit, item);
        })
    }
}